package com.bxn.thymeleaf_springboot.controller;

import com.bxn.thymeleaf_springboot.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class thymeleafController {
    @RequestMapping("/test")
    public String testReturn(Model model) {

        model.addAttribute("msg", "我叼你吗的");
        return "hello";

    }

    @GetMapping("test2")
    public String test2(Model model) {
        User user = new User();
        user.setAge(21);
        user.setName("Jackson");
        user.setFriend(new User("马超", 16));
        model.addAttribute("user", user);
        return "hello2";
    }

    @GetMapping("test3")
    public String test3(Model model) {

        return "hello1";
    }

    @GetMapping("/index")
    public String returnTitle(Model model) {
        model.addAttribute("title", "这是通过java传递进来的title");
        return "hello";
    }


}
